package com.user.rocketmq;


import com.common.Message.vo.statusMessage;
import com.common.RocketMqConstant;

import com.common.Util.ObjectUtil;
import com.common.other.domain.entity.SysLog;
import com.user.dao.SysLogDao;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @program: Member_Perks_Store
 * @description:
 * @author: 无恙
 * @create: 2024-06-21 13:42
 **/

@Slf4j
@Component
@RocketMQMessageListener(
        topic = RocketMqConstant.PRODUCT_UPDATE_TOPIC,
        consumerGroup = RocketMqConstant.PRODUCT_UPDATE_GROUP,
        selectorExpression = RocketMqConstant.PRODUCT_UPDATE_TAG,
        // 指定消费者线程数，默认64，生产中请注意配置，避免过大或者过小
        consumeThreadMax = 5
)
public class statusListener extends BaseMqMessageListener<statusMessage>
        implements RocketMQListener<statusMessage> {

    @Autowired
    private SysLogDao sysLogDao;

    @Override
    protected String consumerName() {
        return "";
    }

    @Override
    protected void handleMessage(statusMessage message) throws Exception {
        log.info("更新权益状态消息：{}",message);
        SysLog sysLog = message.getSysLog();
        com.user.entity.SysLog covert = ObjectUtil.covert(sysLog, com.user.entity.SysLog.class);
        sysLogDao.insert(covert);

    }

    @Override
    protected void overMaxRetryTimesMessage(statusMessage message) {

    }

    @Override
    protected boolean isRetry() {
        return false;
    }

    @Override
    protected boolean isThrowException() {
        return false;
    }

    @Override
    public void onMessage(statusMessage statusMessage) {
        super.dispatchMessage(statusMessage);
    }
}
